package com.kennedy.atoupdate.service;

import com.kennedy.atoupdate.beans.user.SysRole;
import com.kennedy.atoupdate.beans.user.SysUser;
import com.kennedy.atoupdate.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by tao.zeng on 2017/8/2.
 */
@Service
public class SysUserService {
    @Autowired
    private SysUserMapper sysUserMapper;

    SysUser findByUsername(String username) {
        SysUser sysUser = new SysUser();
        sysUser.setUsername(username);
        sysUser = sysUserMapper.selectOne(sysUser);
        List<SysRole> roles = new LinkedList<>();
        roles.add(new SysRole(1l, "ROLE_ADMIN"));
        roles.add(new SysRole(2l, "ROLE_USER"));
        sysUser.setRoles(roles);
        return sysUser;
    }
}
